package com.sharekitchen.service.impl;

import com.sharekitchen.entity.Admin;
import com.sharekitchen.mapper.AdminMapper;
import com.sharekitchen.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    //    校验用户是否存在
    @Override
    public boolean existAdminName(String adminName) {
//        也可以改变mapper返回 int查询多少条
//        如果这个用户能够找到信息,说明已存在,则返回true
        return adminMapper.existAdminName(adminName) != null;
    }

    //    添加用户
    @Override
    public boolean addAdmin(Admin admin) {
        return adminMapper.addAdmin(admin) > 0;
    }



    //    获取用户信息
    @Override
    public Admin findAdminByName(String adminName) {
        return adminMapper.findAdminByName(adminName);
    }

    @Override
    public List<Admin> findAllAdmin() {
        return adminMapper.findAllAdmin();
    }

    @Override
    public Admin findAdminById(int adminId){return adminMapper.findAdminById(adminId);}


    @Override
    public boolean deleteAdminByName(String adminName) {
        return adminMapper.deleteAdminByName(adminName);
    }

    @Override
    public boolean updateAdmin(Admin admin) {
        return adminMapper.updateAdmin(admin);
    }
}
